<!DOCTYPE html>
<html>
<head>
    <title>用户品牌信息表</title>
    <#include "/header.html">
    <script src="${request.contextPath}/statics/libs/layer.js"></script>
</head>
<body>
<style>
    th{
        text-align: center;
    }
     th{
         text-align: center;
     }
    .out1,in1{border:1px inset #ccc;height:20px;overflow-y:hidden;line-height:20px;width:100%}
    img {border-width: 0px 0px 0px 0px}
    .btn{
        padding: 1px 7px;
    }
    .btn-default{
        padding: 6px 12px;
    }
</style>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <div style="float: left">
                <input style="width: 120px" type="text" class="form-control" v-model="q.brandName" @keyup.enter="query" placeholder="品牌名称">
            </div>
            &nbsp;&nbsp;&nbsp;
            <p style="float: left">&nbsp;</p>
            <p style="float: left">&nbsp;</p>
            <div style="float: left">
                <select style="height: 34px;" id="selectUserGzhList" v-model="q.gzhCode">

                </select>
            </div>
            <a class="btn btn-default" @click="query">查询</a>
            <a class="btn btn-default" @click="batchMerge">合并</a>
    </div>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
</div>
<div v-show="!hebing" id="hebing" style="text-align:center">
        <table style="margin: auto;text-align:center;border-collapse:separate; border-spacing:0px 20px;position: center">
            <tr>
                <td>
                    <input style="width: 120px" class="form-control" list="brandName" placeholder="品牌" id="merge" onblur="getValue(this)">
                    <datalist id="brandName" >

                    </datalist>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" class="btn btn-primary" onclick="closeAll()" value="确定"/>
                </td>
            </tr>
        </table>
</div>
<div v-show="!show" class="panel panel-default">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal">
        <div class="form-group">
            <div class="col-sm-2 control-label">品牌名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="bBrandInfo.brandName" placeholder="品牌名称"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
            &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="back" value="返回"/>
        </div>
    </form>
</div>
<div v-show="!showLists" class="panel panel-default" id="showLists">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal">
        <div class="form-group">
            <div class="col-sm-2 control-label">品牌名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="bBrandInfo.brandName" placeholder="品牌名称"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">文章分类</div>
            <div class="col-sm-10">
                <div class="out1" id="out1" exp="">
                    <div class="in1" id="in1" exp="" onmousemove="">
                    </div>
                </div>
                <input style="display: none" type="text" id="code" name="code"/>
                <div class="list" exp="">
                    <input class="browsers" list="type" onchange="xxx()" placeholder="文章分类"/>
                    <datalist id="type" class="chosen-select">

                    </datalist>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">别名</div>
            <div class="col-sm-10">
                <textarea type="text" class="form-control" rows="3" v-model="bBrandInfo.brandAlias" placeholder="别名（请用中文逗号隔开）"></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">关键字</div>
            <div class="col-sm-10">
                <textarea type="text" class="form-control" rows="3" v-model="bBrandInfo.brandKeyWord" placeholder="关键字（请用英文逗号隔开）"> </textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">品牌描述</div>
            <div class="col-sm-10">
                <textarea v-model="bBrandInfo.brandDesc" placeholder="品牌描述"   rows="4" class="form-control"></textarea>
                <!--<input type="text" class="form-control" v-model="bBrandInfo.brandDesc" placeholder="品牌描述"/>-->
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary" @click="Updates" value="确定"/>
            &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="back" value="返回"/>
        </div>
    </form>
</div>
</div>
<script language="javascript" defer>
    $(document).ready(function() {
        $("#code").val("");
        $('#in1').html("");
    });
    function selected(name,code) {
        var ids = $("#code").val();
        if(ids.indexOf(code) == -1){  //没有找到匹配的id
            $("#in1").append("<a href=# onclick=javascript:deleteCode("+code+");><div style='width:auto;float:left;' id="+code+">"+name+';'+" </div></a>");
            $("#"+code).hover(function(){
                $(this).css("background","yellow");},function(){
                $(this).css("background","white");
            });
            //添加隐藏域的值
            ids += code + ",";
            $("#code").val(ids);
        }
        $(".browsers").val(null);
    }
    function deleteCode(code){
        var ids = $("#code").val();
        $("#code").val(ids.replace(code+",",""));
        $("#"+code).remove();
    }
    function xxx() {
        var a=$(".browsers").val();
        console.log($("#"+a))
        var b=$("#"+a).text();
        console.log(b);
        selected(a,b);

    }
    function getValue(e) {
        $("#merge").val(e.value);
    }
    function closeAll() {
        console.log(vm.userId);
        // $("#merge").val();
        console.log( $("#merge").val());
        var ids = getSelectedRows();
        console.log(ids);
        if(ids == null){
            ids[0]=vm.userId;
            var bUserBrandInfo={
                brandIds:ids,
                brandName:$("#merge").val()
            };
        }else{
            var bUserBrandInfo={
                brandName:$("#merge").val(),
                brandIds:ids
            };
        }
        $.ajax({
            type: "POST",
            url: baseURL + "sys/buserbrandinfo/merge",
            contentType: "application/json",
            data: JSON.stringify(bUserBrandInfo),
            success: function(r){
                if(r.code == 0){
                    alert('操作成功', function(index){
                        layer.closeAll();
                        $("#jqGrid").trigger("reloadGrid");
                    });
                }else{
                    alert(r.msg);
                }
            }
        });
    }
</script>
<script src="${request.contextPath}/statics/js/modules/sys/buserbrand.js?_${.now?long}"></script>
</body>
</html>
